﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace JQueryWidget.WidgetWeb
{
    [ViewStateModeById]
    public partial class WebUserControl1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Button1.Text = "adfasdf";

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            TextBox1.Text += "2";
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            HtmlGenericControl div = new HtmlGenericControl("div");
            div.ID = "div1";
            //div.Controls.Add(new Button() { ID = "Button1" });
            this.Controls.Add(div);


            Action<HtmlGenericControl> controlAction = c =>
            {
                if (c.FindControl("Button1") == null)
                {
                    c.InnerHtml = "Can't not find Button1";
                }
                else
                {
                    c.InnerHtml = "Have Found Button1";
                }
            };
            controlAction(div);
        }

    }
}